package com.crm.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.crm.base.ResponseResult;
import com.crm.domain.entity.Transfer;
import com.crm.domain.query.TransferQuery;
import com.crm.service.ITransferService;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(tags = "转派管理")
@RequestMapping("/transfer")
@RequiredArgsConstructor
public class TransferController {
    private final ITransferService transferService;

    @GetMapping("list")
    public ResponseResult list(TransferQuery query){
               Page<Transfer> page=transferService.queryAll(query);
               return ResponseResult.success()
                       .put("rows",page.getRecords())
                       .put("total",page.getTotal());
    }

    @PutMapping("/assignment/{type}/{deptId}/{userId}")
    public ResponseResult assignment(@PathVariable Integer type,@PathVariable Long deptId ,@PathVariable Long userId){
        transferService.change(type,deptId,userId);
        return ResponseResult.success();
    }
}
